3c57bd
@@ -337,17 +337,20 @@
void finishPartition() throws HiveException {
         handleOutputRows(tabFn.finishPartition());
       } else {
         if ( tabFn.canIterateOutput() ) {
-          outputPartRowsItr = tabFn.iterator(inputPart.iterator());
+          outputPartRowsItr = inputPart == null ? null :
+            tabFn.iterator(inputPart.iterator());
         } else {
-          outputPart = tabFn.execute(inputPart);
-          outputPartRowsItr = outputPart.iterator();
+          outputPart = inputPart == null ? null : tabFn.execute(inputPart);
+          outputPartRowsItr = outputPart == null ? null : outputPart.iterator();
         }
         if ( next != null ) {
           if (!next.isStreaming() && !isOutputIterator() ) {
             next.inputPart = outputPart;
           } else {
-            while(outputPartRowsItr.hasNext() ) {
-              next.processRow(outputPartRowsItr.next());
+            if ( outputPartRowsItr != null ) {
+              while(outputPartRowsItr.hasNext() ) {
+                next.processRow(outputPartRowsItr.next());
+              }
             }
           }
         }
@@ -357,8 +360,10 @@
void finishPartition() throws HiveException {
         next.finishPartition();
       } else {
         if (!isStreaming() ) {
-          while(outputPartRowsItr.hasNext() ) {
-            forward(outputPartRowsItr.next(), outputObjInspector);
+          if ( outputPartRowsItr != null ) {
+            while(outputPartRowsItr.hasNext() ) {
+              forward(outputPartRowsItr.next(), outputObjInspector);
+            }
           }
         }
       }
